﻿@using System.Xml;
@using System.IO;
@using System.Text;

@*  <script>
      var currentTrip;
      function getGalleryInfo() {

          var param = $("#tripID").text();
          var data = Object();
          data.param = param;

          $.ajax({
              type: "POST",
              contentType: "application/json; charset=utf-8",
              url: "http://localhost:58872/trip/GetGalleryInfo",
              data: JSON.stringify(data),
              dataType: "json",
              success: function (data) {
                  if (data.Error) {
                      alert(data.Error)
                  } else {
                      currentTrip = data;
                      var divemail = 'email={0}';
                      var divemail = divdate.replace("{0}", data.Author.Email);
                      $("#getemail").append(divdate0);

                  }
              },
              error: function (result) {
                  alert(data.Error);
              }
          });

      }

      $(document).ready(function () {
          getGalleryInfo();
      });
    </script>
*@    



<p id="tripID" style="display:none">@ViewBag.TripId</p>
<div class="gallery-div">
 <div class="sidebar-image-gallery"> 

@{
    string userid = String.Empty;
    string nsid = String.Empty;
    string serverID = String.Empty;
    string title = String.Empty;
    string imageID = String.Empty;
    string secret = String.Empty;
    string farmID = String.Empty;
    string imageURLthumb = String.Empty;
    string imageURLbig = String.Empty;
    string photosetid = String.Empty;
    string email = String.Empty;
    @*<div id="getemail">*@
    email = "gabytzu_06%40yahoo.com";
    @*</div>*@
    string uri = "http://www.flickr.com/services/rest/?method=flickr.people.findByEmail&find_email=" + @email + "&api_key=510ac9cd57a960c919e2b064c2cfea98";
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
    WebResponse response = request.GetResponse();
    Stream strm = response.GetResponseStream();
    XmlTextReader reader = new XmlTextReader(strm);
    }

@{
    while (reader.Read())
    {
        if (reader.Name == "user")
        {
            userid = reader.GetAttribute("id");
            nsid = reader.GetAttribute("nsid");
            string uri2 = "http://www.flickr.com/services/rest/?method=flickr.photosets.getList&user_id=" + @userid + "&api_key=510ac9cd57a960c919e2b064c2cfea98";
            request = (HttpWebRequest)WebRequest.Create(uri2);
            response = request.GetResponse();
            strm = response.GetResponseStream();
            reader = new XmlTextReader(strm);
            break;
        }

    }

    }
       
        @{
            while (reader.Read())
            {
                if (reader.Name == "photoset")
                {
                    photosetid = reader.GetAttribute("id");
                }

                if (reader.Name == "title")
                {
                    reader.Read();
                    if (reader.Value == @ViewBag.TripId.text())
                    {
                        string uri3 = "http://www.flickr.com/services/rest/?method=flickr.photosets.getPhotos&api_key=510ac9cd57a960c919e2b064c2cfea98&photoset_id=" + @photosetid;
                        request = (HttpWebRequest)WebRequest.Create(uri3);
                        response = request.GetResponse();
                        strm = response.GetResponseStream();
                        reader = new XmlTextReader(strm);
                        break;
                    }
                }

            }

            while (reader.Read())
            {
                if (reader.Name == "photo")
                {
                    imageID = reader.GetAttribute("id");
                    secret = reader.GetAttribute("secret");
                    serverID = reader.GetAttribute("server");
                    farmID = reader.GetAttribute("farm");
                    imageURLthumb = "http://farm" + @farmID + ".static.flickr.com/" + @serverID + "/" + @imageID + "_" + @secret + "_s.jpg";
                    imageURLbig = "http://farm" + @farmID + ".static.flickr.com/" + @serverID + "/" + @imageID + "_" + @secret + "_b.jpg";
                            <!-- <img src="@imageURLbig" />-->
                            <!--<a class="fancybox-thumbs" href="@imageURLbig">&nbsp;<img src="@imageURLthumb" alt="" /></a>-->
                            <!--<a class="fancybox-button" href="@imageURLbig">&nbsp;<img src="@imageURLthumb" alt="" /></a>-->
                            <a href="@imageURLbig" target="frame_gallery"><img src="@imageURLthumb" alt="" style="margin-top:5px;margin-left:5px;margin-bottom:5px;"></a>
                                <!--<a class="imPop" href="@imageURLbig" title="sample">  
                                <span><img src="@imageURLthumb" width="64" height="64" alt="sample" border="0" /></span></a>  -->
            
                            
                } 
                            
              
            }
        }
        
    </div>
    
    
    <div class="sidebar-frame">
            <iframe name="frame_gallery" class="gallery-frame"></iframe>
     </div>
    
    
    </div>
    
                  